# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models
from django.contrib import admin

class Article(models.Model):
	STATUS_CHOICES = (
		('d','Draft'),
		('p','Published'),
	)
	title = models.CharField(u'标题',max_length=70)
	body = models.TextField(u'正文')
	created_time = models.DateTimeField(u'创建时间',auto_now_add=True)
	last_modified_time = models.DateTimeField(u'修改时间',auto_now_add=True)
	status = models.CharField(u'文章状态',max_length=1,choices=STATUS_CHOICES)
	

class Catagory(models.Model):
	name = models.CharField(u'名称',max_length=30)
	
	def __unicode__(self):
		return self.name
admin.site.register(Catagory)

class Tag(models.Model):
	name = models.CharField(u'标签',max_length=30)
	
	def __unicode__(self):
		return self.name
admin.site.register(Tag)

class Blog(models.Model):
	title = models.CharField(u'标题',max_length=30)
	content = models.CharField(u'内容',max_length=300)
	author = models.CharField(u'作者',max_length=30)
	created = models.DateTimeField(u'创建时间',auto_now_add=True)
	category = models.ForeignKey(Catagory,verbose_name=u'分类')
	tag = models.ManyToManyField(Tag,verbose_name=u'标签')
	
	def __unicode__(self):
		return self.title
		
admin.site.register(Blog)
		
class Comment(models.Model):
    """
    评论
    """
    blog = models.ForeignKey(Blog,verbose_name='博客')
    name = models.CharField('称呼',max_length=16)
    email = models.EmailField('邮箱')
    content = models.CharField('内容',max_length=240)
    created = models.DateTimeField('发布时间',auto_now_add=True)

    def __unicode__(self):
        return self.content
admin.site.register(Comment)

class User(models.Model):
	username = models.CharField(max_length=30)
	password = models.CharField(max_length=30)
	headImg  = models.FileField(upload_to='./Img/')
	
	def __unicode__(self):
		return self.username
admin.site.register(User)

class Author(models.Model):
	author = models.CharField(max_length=30)
	content = models.CharField(max_length=30)
	
	def __unicode__(self):
		return self.author
admin.site.register(Author)
